<template>
  <!-- 清算账户自动拆借管理申请录入恢复额度页面弹出框-->
  <el-dialog
    title="清算账户自动拆借管理申请录入恢复额度"
    center
    :visible.sync="open"
    width="1024px"
    :close-on-click-modal="false"
    @close="closeFn"
  >
    <el-form ref="settingsForm" :model="formData" :rules="rules" label-width="135px">
      <el-card class="form-card txnInfo-card">
        <div slot="header" class="label-header-msg">
          <span>清算行信息</span>
        </div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="协议号：" prop="prono">
              <el-input v-model="formData.prono" placeholder="协议号" disabled />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="拆入清算行：" prop="cStBrno">
              <el-input v-model="formData.cStBrno" placeholder="拆入清算行" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="拆入清算行名：" prop="cStBrnoName">
              <el-input v-model="formData.cStBrnoName" placeholder="拆入清算行名" disabled />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="拆出清算行：" prop="dStBrno">
              <el-input v-model="formData.dStBrno" placeholder="拆出清算行" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="拆出清算行名：" prop="dStBrnoName">
              <el-input v-model="formData.dStBrnoName" placeholder="拆出清算行名" disabled />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>

      <el-card class="form-card txnInfo-card">
        <div slot="header" class="label-header-msg">
          <span>拆借信息</span>
        </div>
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="拆借金额下限币种：" prop="lowerCurcd">
              <el-input v-model="formData.lowerCurcd" placeholder="拆借金额下限币种" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="拆借金额下限：" prop="amtLowerLmt">
              <HtAmountInput v-model="formData.amtLowerLmt" placeholder="拆借金额下限" disable />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="拆借金额上限币种：" prop="upperCurcd">
              <el-input v-model="formData.upperCurcd" placeholder="拆借金额上限币种" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="拆借金额上限：" prop="amtUpperLmt">
              <HtAmountInput v-model="formData.amtUpperLmt" placeholder="拆借金额上限" disable />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="恢复金额：" prop="amount">
              <HtAmountInput v-model="formData.amount" placeholder="恢复金额" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注：" prop="remarks">
              <el-input type="textarea" v-model="formData.remarks" placeholder="备注" maxlength="256" show-word-limit />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm" :loading="isLoading">提交</el-button>
      <el-button type="warning" @click="reset">重置</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { quotasave } from "@/api/cnaps/saps/clearAcctAutoMng/clear_manage_apply_entry.js";
import { log } from "util";
import HtAmountInput from "@/views/components/HtAmountInput/index.vue";
export default {
  name: "RecoveryQuota",
  components: {HtAmountInput},
  props: {
    dictMap: {
      type: Object,
      default: () => {
        return {};
      },
    },
    formData: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      // 是否显示弹出层
      open: false,
      isLoading: false,
      rules: {
        protoNum: [
          {
            required: true,
            maxlength: 60,
            message: "必填",
            trigger: "blur",
          },
        ],
        dStBrno: [
          {
            required: true,
            message: "必填",
            trigger: "blur",
          },
        ],
        amtLowerLmt: [
          {
            required: true,
            message: "必填",
            trigger: "blur",
          },
        ],
        amtUpperLmt: [
          {
            required: true,
            message: "必填",
            trigger: "blur",
          },
        ],
        amount: [
          {
            required: true,
            message: "必填",
            trigger: "blur",
          },
        ],
        remarks: [
          {
            maxlength: 256,
            message: "必填",
            trigger: "blur",
          },
        ],
      },
    };
  },
  mounted() {},
  methods: {
    // 表单重置
    reset() {
      this.resetForm("settingsForm");
      // this.$set(this, "form", {});
    },
    closeFn() {
      this.open = false;
      this.reset();
    },
    show() {
      this.open = true;
    },
    submitForm() {
      this.$refs["settingsForm"].validate((valid) => {
        if (valid) {
          this.isLoading = true;
          quotasave(this.formData)
            .then((res) => {
              this.msgSuccess("提交成功！");
              this.isLoading = false;
              this.open = false;
              this.$emit("editComplete", true);
            })
            .catch((err) => {
              this.isLoading = false;
            });
        }
      });
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
